/*
 * @Descripttion: 获取当前ip地址
 * @version: 1.0
 * @Author: xin
 * @Date: 2021-09-18 09:08:27
 * @LastEditors: serve
 * @LastEditTime: 2021-09-18 10:36:58
 */

var request = require('request')
var config = require('../config/config')


async function getaddress (req) {
    const ip = req.headers['x-real-ip']
    return await  new Promise((resolve, reject) => {
        request(`${config.map.url}ip?key=${config.map.ipKey}&type=4&ip=${ip}`, {}, (err, res, body) => {
            console.log(body)
            resolve(body)
        })
    })

}
module.exports = {getaddress}
